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

Update to latest TypeScript version and de-dupe versions #26285

Merged
merged 2 commits into from
Jun 17, 2021
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"tailwindcss": "1.1.3",
"taskr": "1.1.0",
"tree-kill": "1.2.2",
"typescript": "4.3.0-beta",
"typescript": "4.3.4",
"wait-port": "0.2.2",
"web-streams-polyfill": "2.1.1",
"webpack-bundle-analyzer": "4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"prompts": "2.1.0",
"rimraf": "3.0.0",
"tar": "4.4.10",
"typescript": "3.8.3",
"typescript": "4.3.4",
"update-check": "1.5.4",
"validate-npm-package-name": "3.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function NoAnonymousDefaultExport({
return { visitor: {} }
}

const warn = onWarning!
const warn: any = onWarning
return {
visitor: {
ExportDefaultDeclaration(path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function ({
const specifier = (binding.path.parent as BabelTypes.ImportDeclaration)
.source.value
// not a match
if (!libs.some((lib) => lib === specifier)) return
if (!libs.some((lib: any) => lib === specifier)) return
}

// only match function calls with names that look like a hook
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function generateStats(
// Webpack 5 requires the compiler to be closed (to save caches)
// Webpack 4 does not have this close method so in order to be backwards compatible we check if it exists
function closeCompiler(compiler: webpack.Compiler | webpack.MultiCompiler) {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
if ('close' in compiler) {
// @ts-ignore Close only exists on the compiler in webpack 5
return compiler.close((err: any) => (err ? reject(err) : resolve()))
Expand Down
6 changes: 3 additions & 3 deletions packages/next/client/performance-relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function onReport(metric: Metric): void {
value: metric.value.toString(),
speed:
'connection' in navigator &&
navigator['connection'] &&
'effectiveType' in navigator['connection']
? (navigator['connection']['effectiveType'] as string)
(navigator as any)['connection'] &&
'effectiveType' in (navigator as any)['connection']
? ((navigator as any)['connection']['effectiveType'] as string)
: '',
}

Expand Down
4 changes: 2 additions & 2 deletions packages/next/client/route-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function prefetchViaDom(
as: string,
link?: HTMLLinkElement
): Promise<any> {
return new Promise((res, rej) => {
return new Promise<void>((res, rej) => {
if (document.querySelector(`link[rel="prefetch"][href^="${href}"]`)) {
return res()
}
Expand All @@ -104,7 +104,7 @@ function prefetchViaDom(
if (as) link!.as = as
link!.rel = `prefetch`
link!.crossOrigin = process.env.__NEXT_CROSS_ORIGIN!
link!.onload = res
link!.onload = res as any
link!.onerror = rej

// `href` should always be last:
Expand Down
2 changes: 1 addition & 1 deletion packages/next/client/script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const loadScript = (props: Props): void => {

const el = document.createElement('script')

const loadPromise = new Promise((resolve, reject) => {
const loadPromise = new Promise<void>((resolve, reject) => {
el.addEventListener('load', function () {
resolve()
if (onLoad) {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
"taskr": "1.1.0",
"terser": "5.5.1",
"text-table": "0.2.0",
"typescript": "3.8.3",
"typescript": "4.3.4",
"unistore": "3.4.1",
"web-vitals": "0.2.4",
"webpack": "4.44.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default function onDemandEntryHandler(

page = posix.normalize(pageUrl)

return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
// Makes sure the page that is being kept in on-demand-entries matches the webpack output
const normalizedPage = normalizePathSep(page)
const entryInfo = entries[normalizedPage]
Expand Down
28 changes: 10 additions & 18 deletions test/integration/typescript-version-warning/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { nextBuild, findPort, launchApp, killApp } from 'next-test-utils'
jest.setTimeout(1000 * 60 * 2)

const appDir = join(__dirname, '../app')
const tsFile = join(appDir, 'node_modules/typescript/index.js')

describe('Minimum TypeScript Warning', () => {
it('should show warning during next build with old version', async () => {
Expand Down Expand Up @@ -34,19 +35,15 @@ describe('Minimum TypeScript Warning', () => {
})

it('should not show warning during next build with new version', async () => {
await fs.rename(
join(appDir, 'node_modules/typescript'),
join(appDir, 'node_modules/typescript-back')
)
const content = await fs.readFile(tsFile, 'utf8')
await fs.writeFile(tsFile, content.replace('3.8.3', '4.3.4'))
const res = await nextBuild(appDir, [], {
stderr: true,
stdout: true,
})
await fs.rename(
join(appDir, 'node_modules/typescript-back'),
join(appDir, 'node_modules/typescript')
)
expect(res.stdout + res.stderr).toContain(
await fs.writeFile(tsFile, content)

expect(res.stdout + res.stderr).not.toContain(
'Minimum recommended TypeScript version is'
)
})
Expand All @@ -57,20 +54,15 @@ describe('Minimum TypeScript Warning', () => {
const handleOutput = (msg) => {
output += msg
}
await fs.rename(
join(appDir, 'node_modules/typescript'),
join(appDir, 'node_modules/typescript-back')
)
const content = await fs.readFile(tsFile, 'utf8')
await fs.writeFile(tsFile, content.replace('3.8.3', '4.3.4'))
const app = await launchApp(appDir, await findPort(), {
onStdout: handleOutput,
onStderr: handleOutput,
})
await fs.writeFile(tsFile, content)
await killApp(app)
await fs.rename(
join(appDir, 'node_modules/typescript-back'),
join(appDir, 'node_modules/typescript')
)

expect(output).toContain('Minimum recommended TypeScript version is')
expect(output).not.toContain('Minimum recommended TypeScript version is')
})
})
12 changes: 4 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16443,14 +16443,10 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript@3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"

typescript@4.3.0-beta:
version "4.3.0-beta"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.0-beta.tgz#8098e7be29032f09827e94b8e3a6befc9ff70c77"
integrity sha512-bl3wxSVL6gWLQFa466Vm5Vk3z0BNx+QxWhb9wFiYEHm6H8oqFd8Wo3XjgCVxAa5yiSFFKgo/ngBpXdIwqo5o0A==
typescript@4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc"
integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==

typescript@^4.1.3:
version "4.1.3"
Expand Down