- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
Closed
Description
I just tried the typescript@next and moduleResolution: 'node12' with @angular/compiler@v13, but tsc -b failed to build:
src/index.ts:1:15 - error TS2305: Module '"@angular/compiler"' has no exported member 'ParsedTemplate'.
1 import type { ParsedTemplate } from '@angular/compiler'
                ~~~~~~~~~~~~~~
src/index.ts:1:37 - error TS1471: Module '@angular/compiler' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
1 import type { ParsedTemplate } from '@angular/compiler'
                                      ~~~~~~~~~~~~~~~~~~~
src/index.ts:2:30 - error TS7016: Could not find a declaration file for module 'synckit'. '/Users/JounQin/Workspaces/Local/test/node_modules/synckit/lib/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/synckit` if it exists or add a new declaration (.d.ts) file containing `declare module 'synckit';`
2 import { createSyncFn } from 'synckit'
                               ~~~~~~~~~
src/worker.ts:1:15 - error TS2305: Module '"@angular/compiler"' has no exported member 'ParsedTemplate'.
1 import type { ParsedTemplate } from '@angular/compiler'
                ~~~~~~~~~~~~~~
src/worker.ts:1:37 - error TS1471: Module '@angular/compiler' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
1 import type { ParsedTemplate } from '@angular/compiler'
                                      ~~~~~~~~~~~~~~~~~~~
src/worker.ts:2:29 - error TS7016: Could not find a declaration file for module 'synckit'. '/Users/JounQin/Workspaces/Local/test/node_modules/synckit/lib/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/synckit` if it exists or add a new declaration (.d.ts) file containing `declare module 'synckit';`
2 import { runAsWorker } from 'synckit'
                              ~~~~~~~~~
src/worker.ts:5:11 - error TS2339: Property 'parseTemplate' does not exist on type 'typeof import("/Users/JounQin/Workspaces/Local/test/node_modules/@angular/compiler/index")'.
5   const { parseTemplate } = await import('@angular/compiler')
            ~~~~~~~~~~~~~
Found 7 errors.
@angular/compiler@v13 is ESM only, ParsedTemplate is typing exported from its types entry.
See https://unpkg.com/browse/@angular/compiler@13.0.0-rc.0/package.json
synckit is both commonjs and ESM compatible.
See https://unpkg.com/browse/synckit@0.6.0/package.json
I have no idea how can it be fixed on my side.
Test source codes:
// worker.ts
import type { ParsedTemplate } from '@angular/compiler'
import { runAsWorker } from 'synckit'
runAsWorker<ParsedTemplate>(async (code: string, filePath: string) => {
  const { parseTemplate } = await import('@angular/compiler')
  return parseTemplate(code, filePath, {
    preserveWhitespaces: true,
    preserveLineEndings: true,
    collectCommentNodes: true,
  })
})Originally posted by @JounQin in #45884 (comment)
Metadata
Metadata
Assignees
Labels
No labels