Loop posts based on permalink term

Got it to work with:

$queried_object = get_queried_object () ;

and

'terms' => $queried_object->slug,

full code now:

    <?php
        $queried_object = get_queried_object () ;
        $posts = array (
            'post_type' => 'writing',
            'posts_per_page' => -1,
            'tax_query' => array(
                array(
                    'taxonomy' => 'type',
                    'field' => 'slug',
                    'terms' => $queried_object->slug,
                ),
            ),
        );
        $loop = new WP_Query( $posts );
        while ( $loop->have_posts() ) : $loop->the_post();
    ?>
            <a href="https://wordpress.stackexchange.com/questions/312112/<?php the_permalink();?>">
                <?php the_title('<h2>','</h2>');?>
            </a>
    <?php endwhile; wp_reset_postdata(); ?>