Skip to content

Design Meeting Notes, 6/6/2016 #9011

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

Closed
DanielRosenwasser opened this issue Jun 8, 2016 · 0 comments
Closed

Design Meeting Notes, 6/6/2016 #9011

DanielRosenwasser opened this issue Jun 8, 2016 · 0 comments
Labels
Design Notes Notes from our design meetings

Comments

@DanielRosenwasser
Copy link
Member

Changes to Automatic Type Definition Inclusion

2 locations of interest for type inclusion:

1. Special inclusion folder (i.e. `types`)
2. `node_modules/@types`
    * How do you find this folder?
    * Started out with walking from `tsconfig.json`, looking at sibling `node_modules`.
    * What about the loose file case? DR found case where tsconfig is not next to `node_modules`? Often happens with test folders.
        * New behavior is walking up the spine to the first dir found.

          ```
          node_modules
            @types
                A
                B
          types
            B
            C
          ```

        * What about watching behavior?
            * That could be a little tricky - you'd be watching the entire strucutre.

Still working on PR, need to iron out a few issues with test runner.

Narrowing Constants in Function Declarations (#8976)

With last week's behavior, this works:

declare const x: string | string[];

function doSomething() {
    if (Array.isArray(x)) {
        var f = function f() {
            x.push("");
        }
        return f;
    }
    return undefined;
}

But not if you change f to be a function declaration:

declare const x: string | string[];

function doSomething() {
    if (Array.isArray(x)) {
        function f() {
            x.push("");
        }
        return f;
    }
    return undefined;
}
  • Has differing behavior in strict mode.
  • Could say that every global variable is uninitialized on entry to every function.
    • That would be an awful experience.
    • But you can't discriminate that well.
    • Any in-betweens will feel inconsistent.

(discussion)

We don't think many people would end up running into this.

Enums and Algebraic Data Types

As we ended up at last week, enums and ADTs are orthogonal. We already have tags.

Index signature parameter types (#5683)

  • Basically boils down to indexers that take types that are subtypes of string (or number).

Have to think more on this.

Non-nullability issues with class properties

  • User proposed checking whether non-nullable properties are initialized within the constructor.
    • Only fixes some problems - virtual calls, indirect method invocations. Not clear what the user wants.
  • Could give users a way of saying that a method initializes a property
    • Now you're just repeating yourself to the compiler (initialization itself as well as declaring that you're doing so).
  • Would really not do a compiler switch.
    • Too coarse-grained.
  • Maybe some sort of modifier?
    • Bang?
  • We don't have a way of understanding the lifetime of any of these members - don't track what happens in super calls, method calls.
  • May be better to not do anything at all, people can use basic syntactic lint rules.
  • We'd love to do something, but it's not clear anything we could do would truly be desirable.
@DanielRosenwasser DanielRosenwasser added the Design Notes Notes from our design meetings label Jun 8, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Notes Notes from our design meetings
Projects
None yet
Development

No branches or pull requests

1 participant