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

Detailed Intl.DateTimeFormatOptions types #38522

Open
wants to merge 2 commits into
base: master
from

Conversation

@johan
Copy link

@johan johan commented May 13, 2020

Fixes #35865: Missing specific types in DateTimeFormatOptions.

This narrows the type info for Intl.DateTimeFormatOptions to legal inputs.

Existing code passing options satisfying the former (overly-lax) types in shipping typescript (and which browsers would thus throw a run-time RangeError exception for), will now be flagged as typescript compile-time errors, instead.

@Kingwl Kingwl mentioned this pull request May 13, 2020
@johan
Copy link
Author

@johan johan commented May 13, 2020

FWIW: the failing tests here are present on master and probably every other branch too (covering whatever might be right or wrong about my implementation here). They look like this, if this is the first time you hear of them:

> ./node_modules/.bin/gulp runtests
[08:28:36] Using gulpfile ~/vc/TypeScript/gulpfile.js
[08:28:36] Starting 'runtests'...
[08:28:36] Starting 'generateLibs'...
[08:28:36] Starting 'buildScripts'...
[08:28:36] Finished 'generateLibs' after 194 ms
[08:28:37] Finished 'buildScripts' after 369 ms
[08:28:37] Starting 'generateDiagnostics'...
[08:28:37] Finished 'generateDiagnostics' after 579 μs
[08:28:37] Starting 'buildShims'...
[08:28:37] Starting 'buildDebugTools'...
[08:28:37] Finished 'buildShims' after 303 ms
[08:28:37] Finished 'buildDebugTools' after 303 ms
[08:28:37] Starting 'buildTsc'...
[08:28:37] Starting 'buildTests'...
[08:28:37] Starting 'buildTypescriptServicesOut'...
[08:28:37] Starting 'buildServerLibraryOut'...
src/harness/vfsUtil.ts:666:47 - error TS2345: Argument of type 'string' is not assignable to parameter of type '"ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined'.

666             return encoding ? buffer.toString(encoding) : buffer;
                                                  ~~~~~~~~


Found 1 error.

[08:28:40] 'buildTsc' errored after 3.1 s
[08:28:40] Error: Process exited with code: 1
    at ChildProcess.<anonymous> (/Users/jhs/vc/TypeScript/scripts/build/utils.js:54:28)
    at ChildProcess.emit (events.js:311:20)
    at ChildProcess.EventEmitter.emit (domain.js:505:15)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
[08:28:40] 'runtests' errored after 3.84 s
[08:28:40] The following tasks did not complete: buildTests, <series>, <series>, buildTypescriptServicesOut, buildServerLibraryOut
[08:28:40] Did you forget to signal async completion?
@johan johan force-pushed the johan:johan/intl-datetimeformatoptions branch from cd31e67 to 7c00ace May 13, 2020
@johan
Copy link
Author

@johan johan commented May 13, 2020

Ah, that was addressed by @Kingwl in #38525 – thank you! Rebased this PR on top of that fix.

@sandersn sandersn added this to Not started in PR Backlog May 19, 2020
PR Backlog automation moved this from Not started to Waiting on author May 20, 2020
src/lib/es5.d.ts Outdated Show resolved Hide resolved
@johan johan force-pushed the johan:johan/intl-datetimeformatoptions branch from 7c00ace to 5d2e09e May 21, 2020
@johan johan requested a review from sandersn May 21, 2020
@johan
Copy link
Author

@johan johan commented Jun 26, 2020

@sandersn, are you taking the opportunity with the 4.0 major release to land PRs like this that stricten overly-loose types?

@sandersn
Copy link
Member

@sandersn sandersn commented Jun 26, 2020

For this PR, I'm waiting for the originating issue #35865 to be discussed and accepted. That happens during regular backlog triage meetings, and is sometimes followed by a design meeting discussion with the whole team.

In general, Typescript doesn't follow semver for a couple of reasons. The first is historical -- we started with the old-school point-release version numbers on a regular release schedule. The second is that is our product is all interface -- every release breaks things, and it's not easy to predict which things will break in a large code base, so there's little value in major-vs-minor releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PR Backlog
  
Waiting on author
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.