{"record":{"id":"0359072e70854316","repo":"swc-project/swc","slug":"jsc-experimental-emitisolateddts-is-enabled-but-th","errorCode":null,"errorMessage":"jsc.experimental.emitIsolatedDts is enabled but the syntax is not TypeScript","messagePattern":"jsc\\.experimental\\.emitIsolatedDts is enabled but the syntax is not TypeScript","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/swc/src/lib.rs","lineNumber":1250,"sourceCode":"\n    #[cfg_attr(\n        debug_assertions,\n        tracing::instrument(name = \"swc::Compiler::apply_transforms\", skip_all)\n    )]\n    fn apply_transforms(\n        &self,\n        handler: &Handler,\n        #[allow(unused)] comments: SingleThreadedComments,\n        #[allow(unused)] fm: Arc<SourceFile>,\n        orig: Option<sourcemap::SourceMap>,\n        config: BuiltInput<impl Pass>,\n    ) -> Result<TransformOutput, Error> {\n        self.run(|| {\n            let program = config.program;\n            let is_typescript_syntax = matches!(config.syntax, Syntax::Typescript(..));\n\n            if config.emit_isolated_dts && !is_typescript_syntax {\n                handler.warn(\n                    \"jsc.experimental.emitIsolatedDts is enabled but the syntax is not TypeScript\",\n                );\n            }\n\n            let source_map_names = if config.source_maps.enabled() {\n                let mut v = swc_compiler_base::IdentCollector {\n                    names: Default::default(),\n                };\n\n                program.visit_with(&mut v);\n\n                v.names\n            } else {\n                Default::default()\n            };\n            #[cfg(feature = \"isolated-dts\")]\n            let dts_code = if is_typescript_syntax && config.emit_isolated_dts {\n                use std::cell::RefCell;","sourceCodeStart":1232,"sourceCodeEnd":1268,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc/src/lib.rs#L1232-L1268","documentation":"Warned by swc's process_js when jsc.experimental.emitIsolatedDts is enabled but the parser syntax is not TypeScript. Isolated .d.ts emission works only on TS syntax; with ecmascript syntax the option is a no-op and SWC tells you so.","triggerScenarios":"Config sets jsc.experimental.emitIsolatedDts: true (or --experimental-emit-isolated-dts) together with jsc.parser.syntax: \"ecmascript\"; also when a shared config applies dts emission to .js/.mjs files.","commonSituations":"Reusing a TypeScript-oriented .swcrc for plain JavaScript files; monorepos with one config across .ts and .js; migrating configs where the parser block was changed but the experimental option was left behind.","solutions":["Set jsc.parser.syntax to \"typescript\" (or \"typescript\" with tsx) for files where you want isolated dts output.","Disable jsc.experimental.emitIsolatedDts for non-TS files or split the config per file type.","Scope the option via overrides/multiple configs so .js inputs do not inherit it."],"exampleFix":"// before\nconst options = {\n  jsc: {\n    parser: { syntax: \"ecmascript\" },\n    experimental: { emitIsolatedDts: true },\n  },\n};\n\n// after\nconst options = {\n  jsc: {\n    parser: { syntax: \"typescript\", tsx: true },\n    experimental: { emitIsolatedDts: true },\n  },\n};","handlingStrategy":"validation","validationCode":"// Validate before calling transform: dts emission requires TS syntax.\nexport function assertDtsConfigConsistent(options: {\n  jsc?: { parser?: { syntax?: string }; experimental?: { emitIsolatedDts?: boolean } };\n}): void {\n  const syntax = options.jsc?.parser?.syntax;\n  const dts = options.jsc?.experimental?.emitIsolatedDts;\n  if (dts && syntax !== 'typescript' && syntax !== 'tsx') {\n    throw new Error(\n      `emitIsolatedDts requires jsc.parser.syntax 'typescript'; got '${syntax}'`\n    );\n  }\n}","typeGuard":"function isTypescriptSyntax(syntax?: string): boolean {\n  return syntax === 'typescript' || syntax === 'tsx';\n}","tryCatchPattern":null,"preventionTips":["Derive emitIsolatedDts from the file type in build tooling instead of a static shared config.","Split .swcrc per syntax or use overrides so .js files never inherit TS-only options.","Lint swc configs for option combinations SWC documents as TS-only."],"tags":["typescript","dts","config","parser-syntax","swc"],"backgroundTag":"config-option-mismatch","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}