Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: use Node16 module resolution #1434

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions md/ts-jsdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export type IntersectionType = Type1 & Type2

```js
// index.js
/** @type { import('./types').IntersectionType } */
/** @type { import("./types.js").IntersectionType } */
const list
```
You can also organise your source types in the same way as [vendored types](#vendor-type-declarations).
Expand Down Expand Up @@ -231,7 +231,7 @@ const fs = require('fs')
* @typedef {import("interface-datastore/src/types").Batch} Batch
* @typedef {import('interface-datastore/src/key')} Key
* @typedef {import('interface-datastore/src/adapter').Query} Query
* @typedef {import('./types').KeyTransform} KeyTransform
* @typedef {import("./types.js").KeyTransform} KeyTransform
*/
```

Expand Down
4 changes: 2 additions & 2 deletions src/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const defaults = merge.bind({
})

/**
* @typedef {import("../types").GlobalOptions} GlobalOptions
* @typedef {import("../types").BuildOptions} BuildOptions
* @typedef {import("../types.js").GlobalOptions} GlobalOptions
* @typedef {import("../types.js").BuildOptions} BuildOptions
* @typedef {import("listr").ListrTaskWrapper} Task
*/

Expand Down
2 changes: 1 addition & 1 deletion src/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Listr from 'listr'
import { rimraf } from 'rimraf'

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
*/

export default new Listr([
Expand Down
4 changes: 2 additions & 2 deletions src/config/tsconfig.aegir.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"allowJs": true,
"checkJs": true,
"target": "ES2022",
"module": "ES2022",
"module": "Node16",
"lib": ["ES2022", "DOM", "DOM.Iterable", "WebWorker"],
"noEmit": false,
"noEmitOnError": true,
Expand All @@ -20,7 +20,7 @@
"sourceMap": true,
// module resolution
"esModuleInterop": true,
"moduleResolution": "node",
"moduleResolution": "Node16",
// linter checks
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
Expand Down
2 changes: 1 addition & 1 deletion src/config/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import merge from '../utils/merge-options.js'
import { isTypescript } from '../utils.js'

/**
* @typedef {import("./../types").Options} Options
* @typedef {import("../types.js").Options} Options
*/

/** @type {Omit<Options, "fileConfig">} */
Expand Down
4 changes: 2 additions & 2 deletions src/dependency-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const ignoredDevDependencies = [

/**
* @typedef {import("listr").ListrTaskWrapper} Task
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").DependencyCheckOptions} DependencyCheckOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").DependencyCheckOptions} DependencyCheckOptions
*/

const tasks = new Listr(
Expand Down
4 changes: 2 additions & 2 deletions src/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const publishPages = promisify(ghPages.publish)
const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").DocsOptions} DocsOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").DocsOptions} DocsOptions
* @typedef {import("listr").ListrTaskWrapper} Task
*/

Expand Down
6 changes: 3 additions & 3 deletions src/docs/type-indexer-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function load (app) {
}

/**
* @param {import("typedoc/dist/lib/output/events").RendererEvent} event
* @param {import("typedoc").RendererEvent} event
*/
const onRendererBegin = event => {
if (!event.urls) {
Expand Down Expand Up @@ -228,7 +228,7 @@ function onResolve (context, decl) {
* For a given UrlMapping, find the nearest package.json file
* and work out if a `typedoc-urls.json` should be generated.
*
* @param {import("typedoc/dist/lib/models/sources/file").SourceReference} source
* @param {import("typedoc").SourceReference} source
* @param {boolean} isMonorepo
* @returns {ProjectContext}
*/
Expand Down Expand Up @@ -262,7 +262,7 @@ function findContext (source, isMonorepo) {
}

/**
* @param {import("typedoc/dist/lib/application").Application} Application
* @param {import("typedoc").Application} Application
* @param {ProjectContext} context
* @returns {Documentation | undefined}
*/
Expand Down
4 changes: 2 additions & 2 deletions src/docs/unknown-symbol-resolver-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ignoreModules = [
* `typedoc-urls.json` files from the `dist` folder of types that need
* documenting. See `type-indexer-plugin.cjs` for how this file is generated.
*
* @param {import("typedoc/dist/lib/application").Application} app
* @param {import("typedoc").Application} app
*/
export function load (app) {
app.converter.addUnknownSymbolResolver((ref, refl, part, symbolId) => {
Expand Down Expand Up @@ -122,7 +122,7 @@ function loadTypedocUrls (moduleName) {
}

/**
* @param {import("typedoc/dist/lib/converter/comments/declarationReference").ComponentPath[] | undefined} refs
* @param {import("typedoc").ComponentPath[] | undefined} refs
*/
function calculateName (refs) {
if (refs == null || refs.length === 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/document-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { compileSnippets } from 'typescript-docs-verifier'
import merge from './utils/merge-options.js'
import { formatCode, formatError, fromRoot, hasTsconfig, readJson } from './utils.js'
/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").DocsVerifierOptions} DocsVerifierOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").DocsVerifierOptions} DocsVerifierOptions
* @typedef {import("listr").ListrTaskWrapper} Task
*/

Expand Down Expand Up @@ -51,8 +51,8 @@ const tasks = new Listr(
userTSConfig,
{
compilerOptions: {
target: 'esnext',
module: 'esnext',
target: 'ES2022',
module: 'Node16',
noImplicitAny: true,
noEmit: true
}
Expand Down
4 changes: 2 additions & 2 deletions src/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import kleur from 'kleur'
import { everyMonorepoProject, pipeOutput } from './utils.js'

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").ExecOptions} ExecOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").ExecOptions} ExecOptions
*/

export default {
Expand Down
20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import testCmd from './cmds/test.js'
import { loadUserConfig } from './config/user.js'

/**
* @typedef {import('./types').BuildOptions} BuildOptions
* @typedef {import('./types').DependencyCheckOptions} DependencyCheckOptions
* @typedef {import('./types').DocsOptions} DocsOptions
* @typedef {import('./types').GlobalOptions} GlobalOptions
* @typedef {import('./types').LintOptions} LintOptions
* @typedef {import('./types').Options} Options
* @typedef {import('./types').PartialOptions} PartialOptions
* @typedef {import('./types').ReleaseOptions} ReleaseOptions
* @typedef {import('./types').TSOptions} TSOptions
* @typedef {import('./types').TestOptions} TestOptions
* @typedef {import("./types.js").BuildOptions} BuildOptions
* @typedef {import("./types.js").DependencyCheckOptions} DependencyCheckOptions
* @typedef {import("./types.js").DocsOptions} DocsOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").LintOptions} LintOptions
* @typedef {import("./types.js").Options} Options
* @typedef {import("./types.js").PartialOptions} PartialOptions
* @typedef {import("./types.js").ReleaseOptions} ReleaseOptions
* @typedef {import("./types.js").TSOptions} TSOptions
* @typedef {import("./types.js").TestOptions} TestOptions
*/

process.on('unhandledRejection', (err) => {
Expand Down
6 changes: 3 additions & 3 deletions src/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { fromRoot, readJson, hasTsconfig, isTypescript, findBinary, hasDocCheck
const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").LintOptions} LintOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").LintOptions} LintOptions
* @typedef {import("listr").ListrTaskWrapper} Task
* @typedef {import("./types").TSOptions} TSOptions
* @typedef {import("./types.js").TSOptions} TSOptions
*/

const tasks = new Listr(
Expand Down
4 changes: 2 additions & 2 deletions src/release-rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import retry from 'p-retry'
import { isMonorepoParent, pkg, everyMonorepoProject, pipeOutput } from './utils.js'

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").ReleaseRcOptions} ReleaseRcOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").ReleaseRcOptions} ReleaseRcOptions
* @typedef {import("listr").ListrTaskWrapper} Task
*/

Expand Down
4 changes: 2 additions & 2 deletions src/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { calculateSiblingVersion } from './check-project/utils.js'
import { isMonorepoProject, hasDocs, glob } from './utils.js'

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").ReleaseOptions} ReleaseOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").ReleaseOptions} ReleaseOptions
* @typedef {import("listr").ListrTaskWrapper} Task
*/

Expand Down
4 changes: 2 additions & 2 deletions src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import kleur from 'kleur'
import { everyMonorepoProject, pipeOutput } from './utils.js'

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
* @typedef {import("./types").RunOptions} RunOptions
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").RunOptions} RunOptions
*/

export default {
Expand Down
4 changes: 2 additions & 2 deletions src/test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @typedef {import("execa").Options} ExecaOptions
* @typedef {import('./../types').TestOptions} TestOptions
* @typedef {import('./../types').GlobalOptions} GlobalOptions
* @typedef {import("../types.js").TestOptions} TestOptions
* @typedef {import("../types.js").GlobalOptions} GlobalOptions
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/test/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @typedef {import("execa").Options} ExecaOptions
* @typedef {import('./../types').TestOptions} TestOptions
* @typedef {import('./../types').GlobalOptions} GlobalOptions
* @typedef {import("../types.js").TestOptions} TestOptions
* @typedef {import("../types.js").GlobalOptions} GlobalOptions
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import rn from './react-native.js'

/**
* @typedef {import("execa").Options} ExecaOptions
* @typedef {import('./../types').TestOptions} TestOptions
* @typedef {import('./../types').GlobalOptions} GlobalOptions
* @typedef {import('./../types').BuildOptions} BuildOptions
* @typedef {import("../types.js").TestOptions} TestOptions
* @typedef {import("../types.js").GlobalOptions} GlobalOptions
* @typedef {import("../types.js").BuildOptions} BuildOptions
*/

const TASKS = [
Expand Down
4 changes: 2 additions & 2 deletions src/test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @typedef {import("execa").Options} ExecaOptions
* @typedef {import('./../types').TestOptions} TestOptions
* @typedef {import('./../types').GlobalOptions} GlobalOptions
* @typedef {import("../types.js").TestOptions} TestOptions
* @typedef {import("../types.js").GlobalOptions} GlobalOptions
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/test/react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @typedef {import("execa").Options} ExecaOptions
* @typedef {import('../types').TestOptions} TestOptions
* @typedef {import('../types').GlobalOptions} GlobalOptions
* @typedef {import("../types.js").TestOptions} TestOptions
* @typedef {import("../types.js").GlobalOptions} GlobalOptions
*/

/**
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/js+ts/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"name": "my-project"
"name": "my-project",
"type": "module"
}
2 changes: 1 addition & 1 deletion test/fixtures/js+ts/src/another.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hello } from './typed'
import { hello } from './typed.js'

export const main = (): void => {
hello('world')
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/js+ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"outDir": "dist",
"allowJs": true,
"checkJs": true,
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2021", "ES2021.Promise", "ES2021.String", "ES2020.BigInt", "DOM", "DOM.Iterable"],
"target": "ES2022",
"module": "Node16",
"lib": ["ES2022", "DOM", "DOM.Iterable", "WebWorker"],
"noEmit": false,
"noEmitOnError": true,
"emitDeclarationOnly": false,
Expand All @@ -20,7 +20,7 @@
"sourceMap": true,
// module resolution
"esModuleInterop": true,
"moduleResolution": "node",
"moduleResolution": "Node16",
// linter checks
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import('./types').ExportedButNotInExports} ExportedButNotInExports
* @typedef {import("./types.js").ExportedButNotInExports} ExportedButNotInExports
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"outDir": "dist",
"allowJs": true,
"checkJs": true,
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2021", "ES2021.Promise", "ES2021.String", "ES2020.BigInt", "DOM", "DOM.Iterable"],
"target": "ES2022",
"module": "Node16",
"lib": ["ES2022", "DOM", "DOM.Iterable", "WebWorker"],
"noEmit": false,
"noEmitOnError": true,
"emitDeclarationOnly": true,
Expand All @@ -20,7 +20,7 @@
"sourceMap": true,
// module resolution
"esModuleInterop": true,
"moduleResolution": "node",
"moduleResolution": "Node16",
// linter checks
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"outDir": "dist",
"allowJs": true,
"checkJs": true,
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2021", "ES2021.Promise", "ES2021.String", "ES2020.BigInt", "DOM", "DOM.Iterable"],
"target": "ES2022",
"module": "Node16",
"lib": ["ES2022", "DOM", "DOM.Iterable", "WebWorker"],
"noEmit": false,
"noEmitOnError": true,
"emitDeclarationOnly": true,
Expand All @@ -20,7 +20,7 @@
"sourceMap": true,
// module resolution
"esModuleInterop": true,
"moduleResolution": "node",
"moduleResolution": "Node16",
// linter checks
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
Expand Down
Loading