disparity between new Project and createIncrementalProgram
See original GitHub issueDescribe the bug
Version: 7.1.0
To Reproduce
I don’t have a fully isolated repro yet. But here is the diff I’m working with:
before:
const tsconfigOptions = {
...compilerCacheOptions,
...layout.tsConfig.content.options,
outDir: layout.build.tsOutputDir,
}
const builder = ts.createIncrementalProgram({
rootNames: layout.nexusModules.concat(layout.app.exists ? [layout.app.path] : []),
options: tsconfigOptions
})
const errors = project.getPreEmitDiagnostics() // is fine
after:
const tsconfigOptions = {
...compilerCacheOptions,
...layout.tsConfig.content.options,
outDir: layout.build.tsOutputDir,
}
const project = new tsm.Project({
compilerOptions: tsconfigOptions,
})
project.addSourceFilesAtPaths(layout.nexusModules.concat(layout.app.exists ? [layout.app.path] : []))
const errors = project.getPreEmitDiagnostics() // has a diagnostic error
unexpected diagnostic error happened with after case:
[
Diagnostic {
_context: ProjectContext {
logger: [ConsoleLogger],
manipulationSettings: [ManipulationSettingsContainer],
_project: [Project],
fileSystemWrapper: [TransactionalFileSystem],
_compilerOptions: [CompilerOptionsContainer],
compilerFactory: [CompilerFactory],
inProjectCoordinator: [InProjectCoordinator],
structurePrinterFactory: [StructurePrinterFactory],
lazyReferenceCoordinator: [LazyReferenceCoordinator],
directoryCoordinator: [DirectoryCoordinator],
_languageService: [LanguageService]
},
_compilerObject: {
file: undefined,
start: undefined,
length: undefined,
messageText: "Cannot find type definition file for 'fs'.",
category: 1,
code: 2688,
reportsUnnecessary: undefined
}
}
]
Expected behavior
Can seamlessly transition from ts.createIncrementalProgram
to new tsm.Project
.
I suspect this isn’t a bug but incorrectly ts-morph usage on my part 🤔 .
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Document --incremental and composite project APIs #31849
I don't see a difference ; so I assume that the incremental build info isn't used at all (although written). Another observation: In...
Read more >How can I use --incremental from TypeScript compiler API?
You will need to create a program using the ts. createIncrementalProgram function. For example: import * as ts from "typescript"; const program ...
Read more >Announcing TypeScript 3.6 - Microsoft Developer Blogs
For leveraging project references, a new createSolutionBuilder function has been exposed, which returns an instance of the new type ...
Read more >Overview - TypeScript
For leveraging project references, a new createSolutionBuilder function has been exposed, which returns an instance of the new type SolutionBuilder .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jasonkuhrt ok, this is fixed and published in 7.1.3. Thanks for reporting it!
For debugging this, it would be good to use the
@ts-morph/bootstrap
example I gave and then figure out where in the typescript compiler it creates the diagnostic then work back from there to figure out why that’s happening. I can look at this later.